package org.hrqing.chess.frame.listener;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hrqing.chess.frame.MainFrame;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author Hrqing
 */
public class ExitMenuItemActionListener implements ActionListener {

    private final MainFrame frame;

    public ExitMenuItemActionListener(MainFrame frame) {
        this.frame = frame;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        int dialog = JOptionPane.showConfirmDialog(frame, "确认退出", "信息", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
        if (dialog == JOptionPane.YES_OPTION) {
            frame.dispose();
        }
    }
}
